extends ../layout/auth

block content
	h1.sr-only Sign In
	.auth-box
		.auth-box-col
			include ../includes/auth-brand
			
		.auth-box-col
			if user
				p.lead Hi #{user.name.first},
				p.lead You're already signed in.
				.toolbar
					if user.isAdmin
						a(href='/keystone').btn.btn-primary Open Keystone
					a(href='/keystone/signout').btn.btn-cancel Sign out
			
			else
				form(method="post", novalidate).auth-form
					input(type='hidden', name=csrf_token_key, value=csrf_token_value)
					.form-group
						label(for='email')= t('email')
						input(type='email', name='email', id='email', value=submitted.email).form-control
					.form-group
						label(for='password')= t('password')
						input(type='password', name='password', id='password').form-control
					
					if isRegister
						button(type='submit').btn.btn-primary= t('register')
						&nbsp;&nbsp;
						a(href='/keystone/signin')= t('Admin.go_to_signin')
					else
						button(type='submit').btn.btn-primary= t('signin')
						&nbsp;&nbsp;
						a(href='/keystone/register')= t('Admin.go_to_register')
				
				//- TODO generic forgotten password functionality
				//- button(type='button').btn.btn-link Forgot Password?
				
block js
	//- Only focus the field after the shake animation is complete
	if messages && messages.error.length
		script setTimeout(function() { try { document.getElementById('email').focus(); } catch(e) {}; }, 800);
	else
		script try { document.getElementById('email').focus(); } catch(e) {};
